home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / dev / c / byteswap.lha / byteswap.h next >
Text File  |  2001-08-08  |  728b  |  45 lines

  1. #if defined __PPC__ && defined __GNUC__
  2.  
  3. __inline static unsigned long SWAP32(unsigned long a )
  4. {
  5.    unsigned long b;
  6.  
  7.    __asm__ ("lwbrx %0,0,%1"
  8.            :"=r"(b)
  9.            :"r"(&a), "m"(a));
  10.  
  11.    return b;
  12.  
  13. }
  14.  
  15. __inline static unsigned short SWAP16(unsigned short a )
  16. {
  17.    unsigned short b;
  18.    __asm__ ("lhbrx %0,0,%1"
  19.            :"=r"(b)
  20.            :"r"(&a), "m"(a));
  21.  
  22.    return(b);
  23. }
  24.  
  25. #endif
  26.  
  27. #if defined mc68000 && defined __GNUC__
  28. __inline static unsigned long SWAP32(unsigned long a)
  29. {
  30.  
  31.    __asm__ ("rol.w #8,%0;swap %0;rol.w #8,%0"
  32.             :"=d"(a):"0"(a));
  33.  
  34.    return(a);
  35. }
  36.  
  37.  
  38. __inline static unsigned short SWAP16(unsigned short a)
  39. {
  40.    __asm__ ("rol.w #8,%0"
  41.             :"=d"(a):"0"(a));
  42.  
  43.    return(a);
  44. }
  45. #endif